package com.sxbbc.common.core.enums;

import com.sxbbc.common.basics.utils.calculation.CalcuUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xiaoky
 * @description 养鸡订单状态枚举
 * @date 2019-05-09
 */
public enum FarmOrderStatusEnums {
	COMFIRE(0,"待支付", true),
	WAIT(1, "已支付,孵化中", false),
	OVER(2,"已完成", true);

	private Integer id;

    private String name;

    private Boolean valid;

    public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Boolean getValid() {
		return valid;
	}

	public void setValid(Boolean valid) {
		this.valid = valid;
	}

	private FarmOrderStatusEnums(Integer id, String name, Boolean valid){
		this.id=id;
		this.name=name;
		this.valid=valid;
	}
	
	public static List<FarmOrderStatusEnums> queryList(){
		List<FarmOrderStatusEnums> list=new ArrayList<FarmOrderStatusEnums>();
		for(FarmOrderStatusEnums o: FarmOrderStatusEnums.values()){
			list.add(o);
		}
		return list;
	}
	
	/**
	 * 查询本版本有效的商品类型
	 * 根据商家类型查询
	 * @return
	 */
	public static List<FarmOrderStatusEnums> queryValidList(){
		List<FarmOrderStatusEnums> list=new ArrayList<FarmOrderStatusEnums>();
		for(FarmOrderStatusEnums o: FarmOrderStatusEnums.values()){
			if (o.getValid()) {
				list.add(o);
			}
		}
		return list;
	}
	
	public static String getName(Integer id){
		String str="";
		for(FarmOrderStatusEnums o: FarmOrderStatusEnums.values()){
			if(CalcuUtils.getInstance().isEquals(id, o.getId())){
				str= o.getName();
				break;
			}
		}
		return str;
	}
	
	public static Boolean isOrderType (Integer id) {
		for(FarmOrderStatusEnums o: FarmOrderStatusEnums.queryValidList()){
			if(CalcuUtils.getInstance().isEquals(id, o.getId())){
				return true;
			}
		}
		return false;
	}
}
